//
//  TabBarManager.m
//  haierapp
//
//  Created by Zhou Bing on 14-8-8.
//  Copyright (c) 2014年 haier. All rights reserved.
//

#import "TabBarManager.h"
#import "HRHomeViewController.h"
#import "HRCategoryViewController.h"
#import "HRCartViewController.h"
#import "HRUserCenterViewController.h"
#import "HRCommonData.h"
#import "HRAppDelegate.h"

@interface TabBarManager (){
    NSInteger preSelectIndex;
}

@end


@implementation TabBarManager

+ (instancetype)shareInstance
{
    static TabBarManager *tabBarManager = nil;
    static dispatch_once_t once;
    dispatch_once(&once, ^
                  {
                      tabBarManager = [[TabBarManager alloc] init];
                  });
    return tabBarManager;
}

- (id)initWithTabBar:(UITabBarController *)tabBarController
{
    self = [super init];
    if (self) {
        self.tabBarController = tabBarController;
    }
    return self;
}


- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
    if ([viewController isKindOfClass:[UINavigationController class]]) {
        UINavigationController *navVC = (UINavigationController *)viewController;
        viewController = [navVC.viewControllers objectAtIndex:0];
    }
    
  
    preSelectIndex=tabBarController.selectedIndex;
    
    return YES;
}

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    
    
    NSInteger selectedIndex=tabBarController.selectedIndex;
    
    /*
    if(selectedIndex==3)
    {
        
        //判断是否已登录(未登录)
//        [self.tabBarController setSelectedIndex:preSelectIndex];
//        
//        UIStoryboard *loginStoryboard=[UIStoryboard storyboardWithName:STORYBOARDNAME_LOGIN bundle:nil];
//
//        UINavigationController *navController=[[UINavigationController alloc]initWithRootViewController:loginStoryboard.instantiateInitialViewController];
//
//        [self.tabBarController setModalPresentationStyle:UIModalPresentationFullScreen];
//        [self.tabBarController presentViewController:navController animated:YES completion:nil];
        
    }
*/

}

@end
